﻿using System.Windows.Forms;

namespace SingletonEvents
{
	public partial class MainForm : Form
	{
		#region Constructors

		public MainForm()
		{
			InitializeComponent();
		}

		#endregion Constructors

		#region Event handlers

		private void CreateChildFormButton_Click(object sender, System.EventArgs e)
		{
			int childFormNumber = Singleton.Instance.GetChildFormNumber();
			bool unsubscribeFromEvents = UbsubscribeFromEventsCheckBox.Checked;

			ChildForm childForm = new ChildForm(childFormNumber, unsubscribeFromEvents);
			childForm.Text = string.Format("Child form #{0}", childFormNumber);
			childForm.Show();

			Singleton.Instance.ActiveChildFormNumber = childFormNumber;
		}

		private void TriggerEventButton_Click(object sender, System.EventArgs e)
		{
			Singleton.Instance.TriggerEvent();
		}

		#endregion Event handlers
	}
}
